package com.east.sng.dao;

import com.east.sng.entity.param.SyslogParam;
import com.east.sng.entity.result.SyslogInfo;
import com.east.sng.utils.RedisCache;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author east
 * @date: 2020/1/3
 * @Description:
 **/
@Repository
@CacheNamespace(implementation = RedisCache.class)
public interface SyslogDao {

    /**
     * 查询全部日志信息
     * @return 日志实例对象列表
     */
    @Select("select * from syslog")
    List<SyslogInfo> selectSyslogs();

    /**
     * 添加日志信息
     * @param syslog 日志信息实例对象
     */
    @Insert("insert into syslog "
            + "values(null,#{syslog.syslogName},#{syslog.loginIp},#{syslog.loginTime})")
    void insertSyslog(@Param("syslog") SyslogParam syslog);


    /**
     * 批量删除日志信息
     *
     * @param syslogIds 日志信息id列表
     * @return 受影响行数
     */
    @Delete({"<script>","delete from syslog where syslog_id in",
            "<foreach collection='list' item='stuId' open='(' separator=',' close=')'>",
            "#{stuId}",
            "</foreach>",
            "</script>"})
    Integer batchDeleteSyslogs(List<Integer> syslogIds);

}

